<?xml version="1.0" encoding="UTF-8"?>
<!-- <?xmlspysamplexml C:\documents\Imperva\Research\WATCH\reduced.xml?> -->
<!-- <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> -->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	<!-- <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/> -->
	<xsl:template match="/">
		<html>
			<head>
	<!-- Table Title Styling -->
	<style>
			#Automation {
				background-color:#FF0000;
			}
			#protected_cve_title {
				background-color:#008000;
			}
			#Need_More_Information_v_title {
				background-color:#0099FF;
			}
			#Statistics_v_title {
				background-color:#FFFF00;
			}
			
	</style>
 
			
			<script>
				function toggleSection(name, btnName) {
					var obj=document.getElementById(name);
					var obj2=document.getElementById('t'+name);
					var btn=document.getElementById(btnName);
					if (obj.style.display == 'none') {
						obj.style.display='';
						obj2.style.display='';
						btn.innerHTML='-';
					} else {
						obj.style.display='none';
						obj2.style.display='none';
						btn.innerHTML='+';
					}
				}
			</script>
			<link rel="stylesheet" type="text/css" href="../common.css" />
			</head>
			<body>
			
			<img src="../img/background.jpg" alt="" id="bg" />

			<div id="content">
			
				<table width="80%"  border="2" cellpadding="5">
					<col width="20"></col>
					<col width="20"></col>
					<thead>
						<tr>
							<th></th>
							<th></th>
							<th>Timestamp</th>
							<th>IP Address</th>
							<th>Method</th>
							<th>Host</th>
							<th>URL</th>
						</tr>
					</thead>
					<tbody>
						<xsl:for-each select="data/packet[not(@dismissed)]">
							<xsl:sort select="target"/>
							<tr>
								<td><button><xsl:attribute name="id">btn<xsl:number count="packet"></xsl:number></xsl:attribute><xsl:attribute name="onclick">toggleSection('pd<xsl:number count="packet"></xsl:number>',this.id)</xsl:attribute>+</button></td>
								<td><xsl:if test="tag/text()='Automation'">
								<img src="/SecurityProject/img/cog.png" alt="" height="32" width="32"></img>
								</xsl:if></td>
								<td><xsl:value-of select="timestamp"></xsl:value-of></td>
								<td>
									<xsl:value-of select="target"/>
								</td>
								<td><xsl:value-of select="field[@name='http.request.method']/@show"></xsl:value-of></td>
								<td><xsl:value-of select="field[@name='http.host']/@show"></xsl:value-of></td>
								<td><a><xsl:attribute name="href">http://<xsl:choose>
									<xsl:when test="field[@name='http.host']/@show!=''"><xsl:value-of select="field[@name='http.host']/@show"></xsl:value-of></xsl:when>
									<xsl:otherwise><xsl:value-of select="target"></xsl:value-of></xsl:otherwise>
								</xsl:choose><xsl:value-of select="field[@name='http.request.uri']/@show"></xsl:value-of></xsl:attribute><xsl:attribute name="target">_blank</xsl:attribute> <xsl:value-of select="field[@name='http.request.uri']/@show"></xsl:value-of></a></td>
							</tr>
								<tr>
									<td>
										<div style="display:none"><xsl:attribute name="id">tpd<xsl:number count="packet"></xsl:number></xsl:attribute>
										<!-- <button type="submit" onClick="javascript:window.location='C:/eclipseProjects/securityProject/SecurityProject/WebContent/welcome.html'" >Create Rule</button> -->
											<form method="post" name="manageRules" id="manageRulesForm" >
										
										
												<xsl:attribute name="action">../ruleFromLog/show?<xsl:for-each select="field">&#38;<xsl:value-of select="@name" />=<xsl:value-of select="@show" /></xsl:for-each>
												</xsl:attribute>
												
												
												
												<p>
													<input type="submit" value="New Rule" />
												</p>		
											</form>
										</div>
									</td>
									<td></td>
									<td>
									<div style="display:none"><xsl:attribute name="id">tpd<xsl:number count="packet"></xsl:number></xsl:attribute>
									<table>
										<tbody>
											<xsl:for-each select="tag">
												<xsl:sort select="text()"></xsl:sort>
											<tr>
												<!-- <xsl:attribute name ="bla3"> <xsl:value-of select="text()"></xsl:value-of> </xsl:attribute> -->
												<td><xsl:value-of select="text()"></xsl:value-of></td>
											</tr>
											</xsl:for-each>
										</tbody>
									</table>
									</div>
									</td>
									<td></td><td></td><td></td>
									<td>
									<div style="display:none"><xsl:attribute name="id">pd<xsl:number count="packet"></xsl:number></xsl:attribute>
									<table width="100%">
									<col width="20%"></col>
									<col width="*"></col>
									<tbody>
										<xsl:for-each select="field">
										<xsl:sort select="@name"></xsl:sort>
										<tr>
											<td><xsl:value-of select="@name"></xsl:value-of></td>
											<td><xsl:value-of select="@show"></xsl:value-of></td>
											
										</tr>
										</xsl:for-each>
									</tbody>
									</table>
									</div>
									</td>
								</tr>
						</xsl:for-each>
					</tbody>
				</table>
				
				</div>
			</body>
		</html>
	</xsl:template>
</xsl:stylesheet>
